package com.xiaozhi.controller;

import com.xiaozhi.VO.LoginVO;
import com.xiaozhi.utils.CommonUtil;
import com.xiaozhi.utils.RedisUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Api(tags = "测试接口")
@RestController
public class testController {

    @Resource
    private RedisUtil redisUtil;

    @ApiOperation("测试获取是否还有生效的邮箱验证码")
    @GetMapping("/session/get")
    public String getSession(HttpSession session) {
        String emailCode = (String) redisUtil.get("emailCode");
        return "get session:"+emailCode;
    }

    @ApiOperation("测试获取或生成Token")
    @GetMapping("/getToken")
    public String getToken(){
        String token=CommonUtil.getCurrentToken();
        String test1 = CommonUtil.createToken("1", "test1", "123456");
        System.out.println(CommonUtil.getTokenInfo(token));
        System.out.println(CommonUtil.getTokenInfo(test1));
        return token;
    }
}
